package cc.wanforme.fsync.entity.device;

import java.io.File;
import java.io.IOException;

/** 盘信息 */
public class PathDeviceInfo {

    private String rootPath;

    private long totalSpace; // 总空间
    private long UsableSpace; // 剩余空间

    /** 当前操作系统的所有逻辑磁盘信息 */
    public static PathDeviceInfo info(String rootPath) throws IOException {
        File file = new File(rootPath);
        if(!file.exists()) {
            return null;
        }

        PathDeviceInfo info = new PathDeviceInfo();
        info.setRootPath(rootPath);
        info.setTotalSpace(file.getTotalSpace());
        info.setUsableSpace(file.getUsableSpace());
        return info;
    }

    public String getRootPath() {
        return rootPath;
    }

    public void setRootPath(String rootPath) {
        this.rootPath = rootPath;
    }

    public long getTotalSpace() {
        return totalSpace;
    }

    public void setTotalSpace(long totalSpace) {
        this.totalSpace = totalSpace;
    }

    public long getUsableSpace() {
        return UsableSpace;
    }

    public void setUsableSpace(long usableSpace) {
        UsableSpace = usableSpace;
    }
}
